<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('chopping列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">

                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:chopping:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:chopping:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:chopping:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:chopping:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-bordered">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:chopping:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:chopping:remove')}]];
    var prefix = ctx + "system/chopping";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "chopping",
            clickToSelect: true,//是否启用点击选中行
            uniqueId: "stackingId",//表主键(用于修改和删除)
            sortName: "stackingId",//必加排序 sortOrder: "asc"默认
            columns: [
                {
                    halign: 'center',
                    align: 'center',
                    checkbox: true
                },
                {
                    title: "序号",
                    halign: 'center',
                    align: 'center',
                    width: 55,
                    formatter: function (value, row, index) {
                        //获取每页显示的数量
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;
                        //获取当前是第几页
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;
                        //返回序号，注意index是从0开始的，所以要加上1
                        return pageSize * (pageNumber - 1) + index + 1;

                    }
                },

                {
                    field: 'stackingId',
                    title: '剁形id',
                    halign: 'center',
                    align: 'center',
                    sortable: true

                },
                {
                    field: 'stackingName',
                    title: '剁形名称',
                    halign: 'center',
                    align: 'center',
                    sortable: true

                },
                {
                    field: 'floorHeight',
                    title: '层高',
                    halign: 'center',
                    align: 'center',
                    sortable: true

                },
                {
                    field: 'floorNum',
                    title: '层数',
                    halign: 'center',
                    align: 'center',
                    sortable: true

                },
                {
                    field: 'floorEach',
                    title: '每层件数',
                    halign: 'center',
                    align: 'center',
                    sortable: true

                },

                {
                    field: 'spare1', title: '图片',
                    formatter: function (value, row, index) {
                        var s;

                        // var url = row.companyImage;
                        // var i = row.companyImage.indexOf("webapps");
                        // var url = row.companyImage.substring(i + 7, row.companyImage.length);
                        // var url = 'F:\idnex.jpg';
                        s = '<a class="view"  href="javascript:void(0)"><img style="width:300;height:40px;" src="' + row.spare1 + '"/></a>';
                        return s;
                    }
                },
                {
                    title: '操作',
                    halign: 'center',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];

                        if (row.stackingId != "") {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.stackingId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.stackingId + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }

                    }
                }]
        };
        $.table.init(options);
    });

    $(document).on('click', 'img', function() {
        var imgUrl = $(this).attr('src');
        var modalHtml = '<div class="modal fade"  tabindex="-1" role="dialog">' +
            '  <div class="modal-dialog modal-lg" role="document">' +
            '    <div class="modal-content">' +
            '      <div class="modal-body">' +
            '        <img style="width: 100%;height: 100%" src="' + imgUrl + '">' +
            '      </div>' +
            '      <div class="modal-footer">' +
            '        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>' +
            '        <a href="' + imgUrl + '" download="' + imgUrl + '" class="btn btn-primary">下载</a>' +
            '      </div>' +
            '    </div>' +
            '  </div>' +
            '</div>';
        $('body').append(modalHtml);
        $('.modal').modal('show');
    });
    $(document).on('hidden.bs.modal', '.modal', function() {
        $(this).remove();
    });
</script>
</body>
</html>


